package com.bw.goods.mvvm.bind;

import androidx.databinding.BindingAdapter;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.bw.goods.mvvm.adpter.CategoryLeftAdpter;
import com.chad.library.adapter.base.BaseQuickAdapter;

public class CategoryRvBind {

//    @BindingAdapter(value = {"leftadpter"})
//    public static void CategorybindGoodsRv(RecyclerView recyclerView, BaseQuickAdapter adapter){
//            LinearLayoutManager manager = new LinearLayoutManager(recyclerView.getContext());
//            manager.setOrientation(LinearLayoutManager.VERTICAL);
//            recyclerView.setLayoutManager(manager);
//            recyclerView.setAdapter(adapter);
//        }
//    @BindingAdapter(value = {"rightAdpter"})
//    public static void CategoryRightGoodsRv(RecyclerView recyclerView, BaseQuickAdapter adapter){
//        GridLayoutManager manager = new GridLayoutManager(recyclerView.getContext(),3);
//        manager.setOrientation(LinearLayoutManager.VERTICAL);
//        recyclerView.setLayoutManager(manager);
//        recyclerView.setAdapter(adapter);
//    }
    @BindingAdapter(value = {"adpter","type"},requireAll = true)
    public static void CategorybindGoodsRv(RecyclerView recyclerView, BaseQuickAdapter adapter,Integer type){
        if(type == 0){
            LinearLayoutManager manager = new LinearLayoutManager(recyclerView.getContext());
            manager.setOrientation(LinearLayoutManager.VERTICAL);
            recyclerView.setLayoutManager(manager);
            recyclerView.setAdapter(adapter);
        }else {
            GridLayoutManager gridLayoutManager = new GridLayoutManager(recyclerView.getContext(),3);
            gridLayoutManager.setOrientation(RecyclerView.VERTICAL);
            recyclerView.setLayoutManager(gridLayoutManager);
            recyclerView.setAdapter(adapter);
        }
    }

}
